package com.kylin.inversion.improve;

public class DependenceInversion {

    public static void main(String[] args) {
        //客户端无需改变
        Person person = new Person();
        person.receive(new Email());

        person.receive(new WeiXin());
    }
}

//定义接口
interface IReceive {
    public String getInfo();
}

class Email implements IReceive {
    public String getInfo() {
        return "电子邮件信息：HelloWorld";
    }
}

//增加微信
class WeiXin implements IReceive {

    @Override
    public String getInfo() {
        return "微信信息：HelloOk";
    }
}

//方式二
class Person {
    public void receive(IReceive iReceive) {
        System.out.println(iReceive.getInfo());
    }
}